package cn.bellychang.leetcode.question226;

/**
 * @author ChangLiang
 * @date 2021/3/15
 */
public class Solution2 {

    public TreeNode invertTree(TreeNode root) {

        if (root == null) {
            return root;
        }
        if (root.left == null && root.right == null) {
            return root;
        }
        TreeNode temp = invertTree(root.left);
        root.left = invertTree(root.right);
        root.right = temp;
        return root;
    }
}
